#include "GameModelThread.h"
#include "GlobalClass.h"

#include <QThread>


GameModelThread::GameModelThread(QObject *parent)
    :QThread(parent)
{
    m_pGameModel = new GameModel(parent);
}

GameModelThread::~GameModelThread()
{
    if(m_pGameModel != nullptr)
    {
        delete m_pGameModel;
    }
}

void GameModelThread::run()
{
    /* 线程的相关代码 */
    qDebug()<<"GameCore ThreadId:"<<QThread::currentThreadId();

    InitOnceInThread();
    if(m_pGameModel->GameInit(m_pGameModel->m_nGameRandom) < 0)
    {
        emit m_pGameModel->s_Critical(_T("[GameModelThread]游戏初始化失败!"));
        return;
    }
    m_pGameModel->GameBegin();
    m_pGameModel->sl_OverGame(GameModel::Game_Status_GameOver, m_pGameModel->m_nGameStatusCode);
}

